class Forum < ActiveRecord::Base
  acts_as_list
  acts_as_tree # can you do this? act as both?
  belongs_to :user
  has_many :topics
  attr_protected :id

  def num_posts
    x = 0
    for topic in self.topics
      x += topic.posts.size
    end
    return x
  end
  
  def latest_topic
    return Topic.find(:first, :conditions => ['forum_id = ?', self.id], :order => 'created_at DESC')
  end
  
  def delete
    for topic in self.topics
      topic.delete
    end
    self.destroy  
  end
end
